#include <iostream>
#include "../Utils/JsonUtil.h"
#include <string>
#include <map>
using namespace std;
void test_request()
{
	string json="{\"operation\":\"negotiation\",\"params\":{\"type\":\"authentication\",\"method\":\"0-RTT-ECDH\",\"others\":\"null\"}}";
	//string json="{\"operation\":\"negotiation111\",\"params\":[{\"type\":\"authentication\"},{\"method\":\"0-RTT-ECHD\"},{\"php\":\"support\"}]}";
	string operaton=JsonUtil::parse_operation(json);
	cout<<operaton<<endl;
	map<string,string> param=JsonUtil::parse_param(json);
	for(const pair<string,string> &p:param)
	{
		cout<<p.first<<" : "<<p.second<<endl;
	}
	cout<<JsonUtil::get_response_json("negotiation ok ,time 256ms",true)<<endl;
}

void test_json2map()
{
	map<string,string> param;
	param.insert(make_pair("pair1","zyl"));
	param.insert(make_pair("pair2","nobody"));
	param.insert(make_pair("pair3","somebody"));
	string jsonMap=JsonUtil:: map_to_json(param);
	cout<<jsonMap<<endl;

	map<string,string> jmap=JsonUtil::json_to_map(jsonMap);
	for(const pair<string,string> &p:jmap)
	{
		cout<<p.first<<" : "<<p.second<<endl;
	}
}

int main()
{
	test_json2map();
	return 0;
}